<?php
/**
 * User: hjd-yao
 * Date: 2019/4/23
 * Time: 10:22
 */

namespace App\Http\Controllers\Backend;


use App\Helpers\SelfResponse;
use App\Http\Controllers\BackendController;
use App\Models\System\CurrencyModel;
use Illuminate\Http\Request;

class CurrencyController extends BackendController
{
    /**
     * @title 编辑币种名称
     * @param Request $request
     * @param $currency_id
     * @return SelfResponse|View
     */
    public function update(Request $request,$currency_id)
    {
        $currency = CurrencyModel::find($currency_id);
        if($request->isMethod('post')){
            $currency->title = $request->post('title');
            $currency->price = $request->post('price');
            if($currency->save()){
                return SelfResponse::success('币种编辑成功','b_Config_websiteSet');
            }
            return SelfResponse::error('编辑失败');
        }else{

            return view('backend::currency.edit',[
                'page_title'=>'编辑币种',
                'currency'=>$currency
            ]);
        }
    }
}